{php include pubTemplate("header")}
<div class="container">

    <nav aria-label="breadcrumb">
        <ol class="breadcrumb">
            <li class="breadcrumb-item"><a href="{SITE_URL}">首页</a></li>
            <li class="breadcrumb-item"><a href="{tsUrl('group')}">小组</a></li>
            <li class="breadcrumb-item"><a href="{tsUrl('group','show',array('id'=>$strGroup['groupid']))}">{$strGroup[groupname]}</a></li>
            <li class="breadcrumb-item active" aria-current="page">发布帖子</li>
        </ol>
    </nav>

    <div class="card">
        <div class="card-body">


            <div class="row">
                <div class="col-md-2"></div>
                <div class="col-md-8">

                    <form method="POST" action="{SITE_URL}index.php?app=topic&ac=add&ts=do&groupid={$groupid}"  enctype="multipart/form-data">

                        <div class="form-group">
                            <label>标题</label>
                            <input name="title" type="text" class="form-control" value="{if $strDraft['title']}{tsTitle($strDraft['title'])}{/if}">
                        </div>

                        {if $arrGroupType}
                        <div class="form-group">
                            <label>类型</label>

                            <select name="typeid" class="form-control">
                                <option value="0">选择类型</option>
                                {loop $arrGroupType $key $item}
                                <option value="{$item[typeid]}">{$item[typename]}</option>
                                {/loop}
                            </select>

                        </div>
                        {/if}


                        <div class="form-group">
                            <label>内容</label>
                            <div>
                                <textarea  id="tseditor" name="content">{if $strDraft['content']}{php echo tsDecode($strDraft['content'])}{/if}</textarea>
                            </div>
                        </div>

                        <div class="form-group">
                            <label>标签</label>
                            <input name="tag" type="text" class="form-control">
                        </div>

                        <div class="form-group">
                            <label>评论</label>

                            <input type="radio" checked="select" name="iscomment" value="0" />允许 <input type="radio" name="iscomment" value="1" />不允许

                        </div>


                        <div class="form-group">
                            <label>回复可读</label>

                            <input type="radio" checked="select" name="iscommentshow" value="0" />不需要 <input type="radio" name="iscommentshow" value="1" />需要

                        </div>


                        <div class="form-group">
                            <label>查看需要</label>
                            <input type="text" name="score" value="0" onkeyup="NumberCheck(this)" /> 积分
                        </div>


                        <!--匿名发布-->
                        {if $TS_SITE['isniming']==1}
                        <div class="form-group">
                            <label>匿名发布：</label>
                            <input type="radio" name="isniming" value="0" checked> 否
                            <input type="radio" name="isniming" value="1"> 是 <span class="text-danger">(匿名发布后用户将无法对内容进行管理)</span>
                        </div>
                        {/if}

                        

                        <!--图片验证码-->
                        {if $TS_SITE['isauthcode']}
                        <div class="form-group">
                            <label>验证码：</label>

                            <div class="offset-0">
                                <input class="form-control form-control-sm w-auto float-left mr-1" name="authcode" />
                                <img class="mt-1" src="{SITE_URL}index.php?app=pubs&ac=code" onclick="javascript:newgdcode(this,this.src);" title="点击刷新验证码" alt="点击刷新验证码" style="cursor:pointer;"/>

                            </div>


                        </div>
                        {/if}


                        <!--人机验证-->
                        {if $TS_SITE['is_vaptcha']}
                        <div class="form-group">
                            <label>人机验证：</label>

                            <div class="offset-0">
                                
                                <div id="vaptchaContainer" style="width: 300px;height: 36px;">
                                    <div class="vaptcha-init-main">
                                    <div class="vaptcha-init-loading">
                                        <a href="/" target="_blank">
                                        <img src="https://r.vaptcha.net/public/img/vaptcha-loading.gif" />
                                        </a>
                                        <span class="vaptcha-text">Vaptcha启动中...</span>
                                    </div>
                                    </div>
                                </div>
                                <script src="https://v-cn.vaptcha.com/v3.js"></script>
                                <script>
                                    vaptcha({
                                        vid: '{$TS_SITE[vaptcha_vid]}',
                                        mode: 'click',
                                        scene: 0, // 场景值 默认0
                                        container: '#vaptchaContainer',
                                        area: 'auto' //验证节点区域,默认 auto,可选值 auto,sea,na,cn
                                    }).then(function (vaptchaObj) {
                                        vaptchaObj.render()
                                        vaptchaObj.renderTokenInput('#vaptcha-token')
                                    })
                                </script>

                            </div>

                            <div id="vaptcha-token"></div>

                        </div>
                        {/if}



                        <input type="hidden" name="groupid" value="{$strGroup[groupid]}" />
                        <input type="hidden" name="token" value="{$_SESSION['token']}" />



                        <button class="btn btn-sm btn-info" type="submit">点击发布</button>

                        <a class="btn btn-sm btn-outline-secondary" href="{tsUrl('group','show',array('id'=>$strGroup[groupid]))}">返回小组</a>

                        <p></p>

                    </form>


                </div>
                <div class="col-md-2"></div>
            </div>



        </div>
    </div>







</div>
{php doAction('tseditor')}
<script>
    //自动保存到草稿箱
    var int=self.setInterval('toDraft()',60000);//轮询执行，一分钟一次
    function toDraft() {
        $(document).ready(function() {
            var title = $('input[name="title"]').val();
            var content = $('textarea[name="content"]').val();
            $.post(siteUrl+'index.php?app=pubs&ac=draft',{'types':'topic','title':title,'content':content},function (rs) {
                if(rs.status==1){
                    tsAlert(rs.msg)
                }
            },'json')
        });
    }
</script>
{php include pubTemplate("footer")}